<template>
  <div class="top-tab">
    <div class="tab-item" 
      v-for="(item, index) in list"
      :key="index"
      :class="tabIndex === index ? 'active' : ''" 
      @click="itemClick(index)">
      <span>{{ item }}</span>
      <span class="line" v-if="tabIndex === index"></span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default: function () {
        return ['产品', '人物', '场景']
      }
    },
    tabIndex: {
      type: Number,
      default: 0
    }
  },
  data () {
    return {
    }
  },
  methods: {
    itemClick (val) {
      this.$emit('update:tabIndex', val)
    },
  }
}
</script>

<style scoped>
.top-tab {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  height: 16vw;
  box-sizing: border-box;
  background: #ffffff;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.12);
  z-index: 10;
}
.tab-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: Source Sans Pro;
  font-size: 4.8vw;
  font-weight: bold;
  line-height: 7.47vw;
  text-align: center;
  letter-spacing: 0px;
  color: #999999;
}
.tab-item.active {
  color: #0072DE;
}
.line {
  width: 15.47vw;
  height: 1.07vw;
  border-radius: 0.53vw;
  background: linear-gradient(94deg, #006EDD 0%, #009CEC 41%, #00A5A5 100%);
}
</style>